<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <img src="" alt="">
  <input type="file" id="file" hidden>
  <button id="btn">选择图片</button>
  <script>
    document.querySelector('#btn').addEventListener('click', function () {
      document.querySelector('#file').click()
    })

    document.querySelector('#file').addEventListener('change', function (e) {
      // console.log(e.target.files[0])
      // img 标签 src 属性值：支持 URL | BASE64格式的字符串
      //　需要将　图片的信息　转换为　url 地址
      const url = URL.createObjectURL(e.target.files[0])
      console.log(url)
    })

  </script>
</body>

</html>